package com.zs.leymovie.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.zs.leymovie.R;
import com.zs.leymovie.adapter.ShowImageGvAdapter;
import com.zs.leymovie.flashview.FlashView;
import com.zs.leymovie.flashview.constants.EffectConstants;

import java.util.ArrayList;

@ContentView(R.layout.activity_show_image)
public class ShowImageActivity extends AppCompatActivity implements View.OnClickListener {
    @ViewInject(R.id.show_image)
    private FlashView mFlashView;
    @ViewInject(R.id.movie_detail_change)
    private ImageView change;
    @ViewInject(R.id.gridview)
    private GridView mGridView;
    @ViewInject(R.id.movie_detail_back)
    private TextView movie_detail_back;

    private int count = 0;
    private ArrayList<String> small;
    private ArrayList<String> large;
    private String movie_name;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewUtils.inject(this);
        Intent intent = getIntent();
        small = intent.getStringArrayListExtra("small");
        large = intent.getStringArrayListExtra("large");
        movie_name = intent.getStringExtra("movie_name");

        movie_detail_back.setText(movie_name);
        mFlashView.setImageUris(large);
        mFlashView.setEffect(EffectConstants.ZOOM_OUT_PAGE_EFFECT);
        change.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.movie_detail_change:
                if (count % 2 == 0) {
                    change.setImageResource(R.mipmap.juzhao_icon2);
                    mFlashView.setVisibility(View.GONE);
                    mGridView.setVisibility(View.VISIBLE);
                    ShowImageGvAdapter adapter = new ShowImageGvAdapter(small, this);
                    mGridView.setAdapter(adapter);

                } else {
                    mFlashView.setVisibility(View.VISIBLE);
                    mGridView.setVisibility(View.GONE);
                }
                count++;
                break;
        }
    }
}
